package com.example.websocket.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ author 韩
 * time: 2024/2/13 1:37
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private boolean flag;
    private Object data;
    private String message;
    public static Result ok(Object data) {
        Result result = new Result();
        result.setFlag(true);
        result.setData(data);
        result.setMessage("操作正确");
        return result;
    }
    public static Result ok() {
        Result result = new Result();
        result.setFlag(true);
        result.setData(null);
        result.setMessage("操作正确");
        return result;
    }


    public static Result error(String message) {
        Result result = new Result();
        result.setFlag(false);
        result.setData(null);
        result.setMessage(message);
        return result;
    }
    public static Result error() {
        Result result = new Result();
        result.setFlag(false);
        result.setData(null);
        result.setMessage("操作失败");
        return result;
    }

}
